# docker build -t registry.lazycat.cloud/appdb/navidrome:20230602 .
# docker run -it -v `pwd`/music:/app/music registry.lazycat.cloud/appdb/navidrome:20230602
FROM node:18 as NODE_DEPS
WORKDIR /app
COPY ui/package.json ui/package-lock.json ./
RUN yarn config set registry https://registry.npm.taobao.org/
RUN yarn install --frozen-lockfile

FROM node:18 as NODE_BUILD
WORKDIR /app
ADD . /app
COPY --from=NODE_DEPS /app/node_modules /app/ui/node_modules
RUN make buildjs

FROM golang:1.19.9-alpine3.18 as GO_BUILD
WORKDIR /app
COPY --from=NODE_BUILD /app /app
RUN wget https://gitee.com/clh21/sh/raw/master/mirror.sh && sh ./mirror.sh; rm -f mirror.sh
RUN apk update \
    && apk add --no-cache \
    make git gcc libc-dev pkgconfig taglib-dev g++ zlib-dev
ENV GOPROXY=https://goproxy.cn,direct
RUN make download-deps
RUN make build

FROM alpine:3.18
LABEL maintainer="chenlianghong<clh021@gmail.com>"
RUN wget https://gitee.com/clh21/sh/raw/master/mirror.sh && sh ./mirror.sh; rm -f mirror.sh
RUN apk update \
    && apk add --no-cache \
    gcc libc-dev taglib-dev g++ zlib-dev

WORKDIR /app
COPY --from=GO_BUILD /app/navidrome /app/

ENV TZ=Asia/Shanghai
EXPOSE 4533
ENTRYPOINT [ "/app/navidrome" ]
CMD [ "--datafolder=/app/data", "--musicfolder=/app/music" ]
